<?php
/**
 * Created by PhpStorm.
 * User: Guangpeng Chen
 * Date: 14-9-4
 * Time: 上午10:35
 */
// $token = md5('pft_cgp_225800');
// if ($_REQUEST['token']!=$token) {
    // exit;
// }
include 'function.php';

define('ROOT_PATH','/var/www/html/new/');
define('FX_PATH', ROOT_PATH.'d/class/');

include FX_PATH . 'Log.class.php';

if(!class_exists('go_sql')) {
    include ROOT_PATH.'conf/le.je';
    $le = new go_sql();
    $le->connect();
}

$sql = "SELECT id,dname FROM pft_member WHERE status=0 AND dtype IN(0,1)";
//$sql = "SELECT COUNT(*) FROM pft_member";
$le->query($sql);
$ds = array();
//print_r($le->fetch_assoc());
//exit;
while( $l = $le->fetch_assoc() ) {
    $ds[$l['id']] =$l['dname'];
}
//print_r($ds);
$saveStr = "<?php\nreturn " . var_export($ds, true)."\n?>";
$fileName = dirname(__FILE__) . "/Member.cache.php";
if (!$handle = fopen($fileName, 'w')) {
    \pft\Log\Log::writeLog( date('Y-m-d H:i:s') . "|不能打开文件 $fileName", 'log.log');
    exit;
}
if (fwrite($handle, $saveStr) === FALSE) {
    \pft\Log\Log::writeLog( date('Y-m-d H:i:s') . "|不能写入到文件 $fileName", 'log.log');
    exit;
}
\pft\Log\Log::writeLog( date('Y-m-d H:i:s') ."|会员静态数据生成成功", 'log_mem.log');